package com.ksd.api.utils;

import java.io.IOException;
import java.io.InputStream;

public class InputStreamUtil {
    public static byte[] read(InputStream is) {
        byte[] dateByte = new byte[10240];
        byte[] dataTemp = new byte[8192];
        int len = 0;
        int totalLen = 0;
        try {
            while ((len = is.read(dataTemp)) > 0) {
                System.arraycopy(dataTemp, 0, dateByte, totalLen, len);
                totalLen += len;
            }
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }

        byte[] recvData = new byte[totalLen];
        System.arraycopy(dateByte, 0, recvData, 0, totalLen);
        return recvData;
    }
}